/*
   Copyright (c) 2023 李伟国
   learner-platform is licensed under Mulan PSL v2.
   You can use this software according to the terms and conditions of the Mulan PSL v2. 
   You may obtain a copy of Mulan PSL v2 at:
               http://license.coscl.org.cn/MulanPSL2 
   THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.  
   See the Mulan PSL v2 for more details. 
*/

package cn.platform.mapper;

import cn.platform.entity.Essay;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

@Mapper
public interface EssayMapper extends BaseMapper<Essay> {
    Page<Essay> selectAll(@Param("page") Page page);

    /**
     * 通过文章的类别和分类查找文章
     * @param categories 类别
     * @param classifications 分类
     * @return 文章列表
     */
    Page<Essay> selectByCategoriesAndClassifications(@Param("page") Page page, @Param("categories") String categories, @Param("classifications") String... classifications);

    /**
     * 通过文章的类别和标签查找文章
     * @param categories 类别
     * @param labels 标签
     * @return 文章列表
     */
    Page<Essay> selectByCategoriesAndLabels(@Param("page") Page page, @Param("categories") String categories, @Param("labels") String... labels);

    /**
     * 通过文章的类别和作者id查找文章
     * @param categories 类别
     * @param authorId 作者id
     * @return 文章列表
     */
    Page<Essay> selectByCategoriesAndAuthorId(@Param("page") Page page, @Param("categories") String categories, @Param("authorId") Long authorId);

    Page<Essay> selectByCategoriesAndAuthorIdPrinciple(@Param("page") Page page, @Param("categories") String categories, @Param("authorId") Long authorId);
    /**
     * 通过文章的id修改文章的状态
     * @param id id
     * @param status 状态
     * @return 修改的行数
     */
    Integer updateStatusById(@Param("id") Long id, @Param("status") String status);

    Page<Essay> selectByCategoriesAndHeadline(@Param("page") Page page,
                                              @Param("categories") String categories,
                                              @Param("headline") String headline);
}
